<!-- 应收费添加 -->
<template>
  <div>
    <h2>基本信息</h2>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="货主单位" prop="Shipper">
        <el-input v-model="form.Shipper" placeholder="请输入货物名称"></el-input>
      </el-form-item>
      <el-form-item label="结算方式" prop="payName">
        <el-radio-group v-model="form.payName">
        <el-radio label="微信支付" value=""></el-radio>
        <el-radio label="支付宝支付" value=""></el-radio>
        <el-radio label="银联支付" value=""></el-radio>
        <el-radio label="企业支付" value=""></el-radio>
        <el-radio label="线下支付" value=""></el-radio>
        <el-radio label="其他" value=""></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="吨位(立方米)" prop="tonnage">
        <el-input v-model="form.tonnage" placeholder="请输入规格"></el-input>
      </el-form-item>
      <el-form-item label="单价(元/立方米)" prop="units">
        <el-input v-model="form.units"></el-input>
      </el-form-item>
      <el-form-item label="金额" prop="money">
        <el-input v-model="form.money"></el-input>
      </el-form-item>
      <el-form-item label="业务日期" prop="businDate">
        <el-date-picker v-model="form.businDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
          :style="{width: '100%'}" placeholder="请选择日期" clearable></el-date-picker>
      </el-form-item>
      <el-form-item label="经办人" prop="operator">
        <el-input v-model="form.operator"></el-input>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="form.remark"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit(form)">提交</el-button>
        <el-button type="Danger" @click="QXCollectionFrom">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>


<script>
import axios from "axios";
export default {
  data() {
    return {
      form: {
        Shipper:"", 
        payName:"",
        tonnage:"", 
        units:"",
        money:"",
        businDate:"",
        operator:"",
        remark:"",
      },
      rules: {
        Shipper: [{
          required: true,
          message: '外协单位',
          trigger: 'blur'
        }],
        payName: [{
          required: true,
          message: '结算方式',
          trigger: 'blur'
        }],
        tonnage: [{
          required: true,
          message: '吨位',
          trigger: 'change'
        }],
        units: [{
          required: true,
          message: '单价',
          trigger: 'change'
        }],
        money: [{
          required: true,
          message: '金额',
          trigger: 'blur'
        }],
        businDate: [{
          required: true,
          message: '业务日期',
          trigger: 'change'
        }],
        operator: [{
          required: true,
          message: '经办人',
          trigger: 'blur'
        }],
        remark: [{
          required: false,
          message: '备注',
          trigger: 'blur'
        }],
      },
    };
  },
  methods: {
    onSubmit(form) {
      this.axios({
        url: "https://localhost:44331/api/app/cargo_Information/cargo",
        method: "post",
        data: form,
      }).then((res) => {
        if (res.status == 200) {
          this.$message.success("添加成功");
          this.$router.push("/Show/Collect_Fee");
        } else {
          this.$message.error("添加失败");
          this.reload(); //局部刷新
        }
      });
    },
    QXCollectionFrom() {
      this.$router.push("/Show/Collect_Fee");
    },
  },
};
</script>